package com.infoland.afanmall.model.order.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatImageView;
import android.widget.LinearLayout;

import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.infoland.afanmall.R;
import com.infoland.afanmall.base.util.LogKit;
import com.infoland.afanmall.base.util.StatusBarKit;
import com.infoland.afanmall.base.util.ToolsKit;
import com.infoland.afanmall.model.order.fragment.AllFragment;
import com.infoland.afanmall.model.order.fragment.DFHFragment;
import com.infoland.afanmall.model.order.fragment.DFKFragment;
import com.infoland.afanmall.model.order.fragment.DSHFragment;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 我的订单Activity
 */

public class MyOrderActivity extends AppCompatActivity {

    @BindView(R.id.order_my_tab)
    SlidingTabLayout orderMyTab;
    @BindView(R.id.order_my_view_page)
    ViewPager orderMyViewPage;
    @BindView(R.id.order_my_back)
    AppCompatImageView orderMyBack;
    @BindView(R.id.pay_success_title)
    LinearLayout paySuccessTitle;
    private ArrayList<Fragment> mFragments = new ArrayList<>();
    private String[] mTitles = {"全部", "待付款", "待发货", "待收货",};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.order_my_activity);
        ButterKnife.bind(this);
        StatusBarKit.immersiveBlackTitleText(this, paySuccessTitle);
        mFragments.add(new AllFragment());
        mFragments.add(new DFKFragment());
        mFragments.add(new DFHFragment());
        mFragments.add(new DSHFragment());
//        mFragments.add(new PJFragment());
        orderMyTab.setViewPager(orderMyViewPage, mTitles, this, mFragments);
        orderMyViewPage.setCurrentItem(0);
        orderMyViewPage.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            }

            @Override
            public void onPageSelected(int position) {
                LogKit.E("  onPageSelected ", "  " + position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        orderMyTab.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                LogKit.E("  onTabSelect ", "  " + position);
            }

            @Override
            public void onTabReselect(int position) {
                LogKit.E("  onTabReselect ", "  " + position);
            }

        });
        initData();
    }

    private void initData() {
    }


    @OnClick(R.id.order_my_back)
    public void onViewClicked() {
        finish();
    }
    @Override
    protected void onDestroy() {
        ToolsKit.deleteOKHttp(this);
        super.onDestroy();
    }
}
